<template>
  <div>
    <div class="popup-layer1 cart-pop hide">
        <div class="popup-mask "></div>
        <div class="popup-box ipx-pad">
            <div class="popup-t">
              <div class="cart-icon content-icon " style="visibility: visible;transition: all 0.6s ease 0s;" @click="closeCar()">
                <div class="m320z8 cart-icon-point ">
                  <span class="mJQBuZ mXYyd4 totalnum2" style="max-width: 100%; overflow: hidden; text-overflow: ellipsis; word-break: break-all; white-space: nowrap;">1</span>
                </div>
              </div>
              <div class="content-title flex">
                <div class="select-btn checked title-select-btn checkbox "></div>
                <span class="global">全选</span>
                <span class="desc flex-item oneline-overflow-ellipsis">(已选1件，共0.7kg)</span>
                <span class="btn">
                  <span class="delete-btn">清空购物车</span>
                </span>
              </div>
            </div>
            <div class="popup-content">
              <div class="cart-content" style="padding-bottom: 50px;">
                <div class="content-item">
                  <ul style="list-style: none;padding-left:0;" class="carul">
                    <li class="goods-list">
                      <div class="select-btn  checkbox checked  "></div>
                      <div class="goods-item ">
                        <div class="goods-item-img-box">
                          <img :src="imgUrl+'/upload/55b9c77dNf1f38fa9.jpg'" class="goods-item-img" style="background: none;">
                        </div>
                        <div class="goods-item-info">
                          <div class="title ">无核夏黑葡萄约700g/份</div>
                          <div class="cart-price-single">
                            <div class="tags-box">
                              <span class="promotion-tags promotion-tags-full" style="background: -webkit-linear-gradient(left top, rgb(255, 200, 55), rgb(255, 150, 51));">
                                <span style="color: #fff;">直降</span>
                              </span>
                            </div>
                            <div class="goods-price single-price">
                              <div class="row">
                                <label class="real_Price" style="font-size: 14px; line-height: 17px;">￥28.8</label>
                                <label class="basic_Price" style="font-size: 12px; line-height: 15px;">￥32.8</label>
                              </div>
                            </div>
                          </div>
                          <div class="addCart flex add-cart">
                            <div class="add" @click="add()"></div>
                            <div class="num">{{totalnum}}</div>
                            <div class="minus"></div>
                          </div>
                        </div>
                      </div>
                    </li>
                     <li class="goods-list car1" style="display:none">
                      <div class="select-btn  checkbox checked  "></div>
                      <div class="goods-item ">
                        <div class="goods-item-img-box">
                          <img :src="imgUrl+'/upload/57106905N6cd6d1a8.jpg'" class="goods-item-img" style="background: none;">
                        </div>
                        <div class="goods-item-info">
                          <div class="title ">精选西红柿约500g/份</div>
                          <div class="cart-price-single">
                            <div class="tags-box">
                              <span class="promotion-tags promotion-tags-full" style="background: -webkit-linear-gradient(left top, rgb(255, 200, 55), rgb(255, 150, 51));">
                                <span style="color: #fff;">直降</span>
                              </span>
                            </div>
                            <div class="goods-price single-price">
                              <div class="row">
                                <label class="real_Price" style="font-size: 14px; line-height: 17px;">￥5.46</label>
                                <label class="basic_Price" style="font-size: 12px; line-height: 15px;">￥4.46</label>
                              </div>
                            </div>
                          </div>
                          <div class="addCart flex add-cart">
                            <div class="add"></div>
                            <div class="num">1</div>
                            <div class="minus"></div>
                          </div>
                        </div>
                      </div>
                    </li>
                  </ul>
                  <ul style="list-style: none;padding-left:0;" class="carul" v-for="li in car" :key="'car'+li.id">
                    <!-- <li class="goods-list">
                      <div class="select-btn  checkbox checked  "></div>
                      <div class="goods-item ">
                        <div class="goods-item-img-box">
                          <img :src="imgUrl+'/upload/55b9c77dNf1f38fa9.jpg'" class="goods-item-img" style="background: none;">
                        </div>
                        <div class="goods-item-info">
                          <div class="title ">无核夏黑葡萄约700g/份</div>
                          <div class="cart-price-single">
                            <div class="tags-box">
                              <span class="promotion-tags promotion-tags-full" style="background: -webkit-linear-gradient(left top, rgb(255, 200, 55), rgb(255, 150, 51));">
                                <span style="color: #fff;">直降</span>
                              </span>
                            </div>
                            <div class="goods-price single-price">
                              <div class="row">
                                <label class="real_Price" style="font-size: 14px; line-height: 17px;">￥28.8</label>
                                <label class="basic_Price" style="font-size: 12px; line-height: 15px;">￥32.8</label>
                              </div>
                            </div>
                          </div>
                          <div class="addCart flex add-cart">
                            <div class="add"></div>
                            <div class="num">1</div>
                            <div class="minus"></div>
                          </div>
                        </div>
                      </div>
                    </li> -->
                    <li class="goods-list" style="display:none">
                      <span class="select-btn  checkbox checked" style="display:inline-block"></span>
                      <div class="goods-item ">
                        <div class="goods-item-img-box">
                          <img :src="imgUrl+'/'+li.imgUrl" class="goods-item-img" style="background: none;">
                        </div>
                        <div class="goods-item-info">
                          <div class="title ">{{li.title}}</div>
                          <div class="cart-price-single">
                            <div class="tags-box">
                              <span class="promotion-tags promotion-tags-full" style="background: -webkit-linear-gradient(left top, rgb(255, 200, 55), rgb(255, 150, 51));">
                                <span style="color: #fff;">直降</span>
                              </span>
                            </div>
                            <div class="goods-price single-price">
                              <div class="row">
                                <label class="real_Price" style="font-size: 14px; line-height: 17px;">{{li.realprice}}</label>
                                <label class="basic_Price" style="font-size: 12px; line-height: 15px;">{{li.fullprice}}</label>
                              </div>
                            </div>
                          </div>
                          <div class="addCart flex add-cart">
                            <div class="add"></div>
                            <div class="num">1</div>
                            <div class="minus"></div>
                          </div>
                        </div>
                      </div>
                    </li>
                  </ul>
                </div>
              </div>
            </div>
        </div>
    </div>
    <div class="bar ipx-pad">
      <div class="cart-icon icon " style="transition: top 0.6s ease 0s;visibility: visible;" @click="openCar()">
          <div class="m320z8 cart-icon-point ">
            <span class="mJQBuZ mXYyd4 totalnum" style="max-width: 100%; overflow: hidden; text-overflow: ellipsis; word-break: break-all; white-space: nowrap;">{{totalnum}}</span>
          </div>
      </div>
      <div class="price">
        <div class="price-warp">
          <span class="price-span">￥31.6</span>
          <span class="discount">已减8元</span>
        </div>
      </div>
      <div class="btn" style="background: linear-gradient(90deg, #00be34, #00cb1e);">
        <div class="ui-flexbox  h-center v-center" style="z-index: 999; height: 50px; background-color: transparent; margin-left: 0px; margin-right: 0px; text-align: center;">
          <div style="position: absolute; top: 0px; left: 0px; right: 0px; bottom: 0px; background-color: transparent; z-index: -1;"></div>
          <span class="mJQBuZ " style="max-width: 100%; overflow: hidden; text-overflow: ellipsis; word-break: break-all; white-space: nowrap; font-size: 16px; color: rgb(255, 255, 255); font-weight: bold;">去结算</span>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: ["goodsId"],
  data() {
    return {
      // 购物车数据
      cars: this.cars["goodsId"],
      car: [],
      totalnum: 1,
      selectnum: 1
    };
  },
  created() {
    this.getCar();
  },
  methods: {
    add() {
      // const goods= document.querySelector('.goods-list');
      // console.dir(goods);
      var num=1;
      if(num>=1){
        num++
      }
      console.log(num)
    //  num.innerText=num++
    },
    async getCar() {
      var { data, data: { result } } = await this.axios({
        methods: "get",
        url: "/car"
      });
      this.car = result;
    },
    openCar() {
      const popupLayer = document.querySelector(".popup-layer1");
      const icon = document.querySelector(".icon");
      const price = document.querySelector(".price");
      const PopupBox = document.querySelector(".popup-box");
      popupLayer.className = "popup-layer1 cart-pop";
      icon.style.visibility = "hidden";
      price.className = "price open";
      PopupBox.className = "popup-box ipx-pad popup-box-show";
    },
    closeCar() {
      const popupLayer = document.querySelector(".popup-layer1");
      const icon = document.querySelector(".icon");
      const price = document.querySelector(".price");
      const PopupBox = document.querySelector(".popup-box");
      popupLayer.className = "popup-layer1 cart-pop hide";
      icon.style.visibility = "visible";
      price.className = "price";
      PopupBox.className = "popup-box ipx-pad popup-box-hide";
    }
  }
};
</script>

<style lang="scss" scoped>
.popup-layer1 {
  position: fixed;
  left: 0;
  top: 0;
  width: 100vw;
  height: 100%;
  background: transparent;
  z-index: 1002;
  .popup-mask {
    position: absolute;
    left: 0;
    width: 100%;
    top: 0;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
  }
  .popup-box-show {
    transform: translateY(0);
    transition: all 0.6s;
  }
  .popup-box-hide {
    transform: translateY(100%);
    transition: all 0.6s;
  }
  .popup-box {
    height: auto;
    max-height: 80%;
    display: -webkit-box;
    bottom: 0;
    background: #fff;
    border-radius: 10px 10px 0 0;
    color: #333;
    flex-direction: column;
    box-sizing: border-box;
    position: absolute;
    left: 0;
    width: 100%;
    .popup-t {
      text-align: left;
      margin: 0;
      font-weight: 400;
      font-size: 16px;
      line-height: 22px;
      position: relative;
      .cart-icon {
        width: 50px;
        height: 50px;
        background: url("http://127.0.0.1:8088/upload/cart.2da9496d.png")
          no-repeat;
        background-size: 50px;
        background-position: 0 100%;
      }
      .content-icon {
        position: absolute;
        left: 10px;
        top: -60px;
        z-index: 41;
        .cart-icon-point {
          position: absolute;
          top: -5px;
          left: 33px;
          right: auto;
          min-width: 18px;
          height: 18px;
          .mJQBuZ {
            display: inline-block;
            background-color: initial;
          }
          .mXYyd4 {
            color: #fff !important;
            font-size: 10px !important;
          }
        }
        .m320z8 {
          display: flex;
          justify-content: center;
          align-items: center;
          line-height: 16px;
          border-radius: 32px;
          z-index: 1;
          background-color: #ff5757 !important;
        }
      }
      .content-title {
        font-size: 12px;
        color: #333;
        min-height: 36px;
        line-height: 36px;
        position: relative;
        display: flex;
        .select-btn {
          margin-top: 7px;
        }
        .content-title::after {
          height: 1px;
          content: "";
          width: auto;
          border-top: 1px solid #f5f5f5;
          position: absolute;
          bottom: 0;
          z-index: 10;
        }
        .checked {
          background: url("http://127.0.0.1:8088/upload/eglass-check.png");
          background-size: 22px 22px;
          background-repeat: no-repeat;
          background-position: 50% 50%;
        }
        .title-select-btn {
          height: 42px;
          width: 42px;
          margin-top: -4px;
          margin-bottom: -4px;
          display: inline-block;
        }
        .checkbox {
          background-image: url("http://127.0.0.1:8088/upload/check.png");
          background-size: 17px 17px;
          background-repeat: no-repeat;
          background-position: 50% 50%;
        }
        .global {
          padding-right: 5px;
        }
        .desc {
          color: #666;
        }
        .flex-item {
          -webkit-box-flex: 1;
          -webkit-flex: 1;
          flex: 1 1;
          overflow: hidden;
        }
        .oneline-overflow-ellipsis {
          display: block;
          overflow: hidden;
          white-space: nowrap;
          text-overflow: ellipsis;
          word-break: break-all;
        }
        .btn {
          .delete-btn {
            padding: 0 10px 0 20px;
            background: url("http://127.0.0.1:8088/upload/delete.png") no-repeat;
            background-size: 15px;
            color: #999;
            font-size: 12px;
          }
        }
      }
    }
    .popup-content {
      flex: 1 1;
      overflow-y: scroll;
      .cart-content {
        .content-item {
          position: relative;
          .goods-list {
            display: flex;
            .select-btn {
              width: 42px;
              height: 70px;
              position: relative;
              z-index: 1;
            }
            .checkbox {
              background-image: url("http://127.0.0.1:8088/upload/check.png");
              background-size: 17px 17px;
              background-repeat: no-repeat;
              background-position: 50% 50%;
            }
            .checked {
              background: url("http://127.0.0.1:8088/upload/eglass-check.png");
              background-size: 22px 22px;
              background-repeat: no-repeat;
              background-position: 50% 50%;
            }
            .goods-item {
              min-height: 50px;
              padding: 10px 10px 10px 60px;
              position: relative;
              overflow: hidden;
              flex: 1 1;
              .goods-item-img-box {
                height: 50px;
                width: 50px;
                top: 10px;
                left: 0;
                position: absolute;
                border-radius: 4px;
                overflow: hidden;
                .goods-item-img {
                  width: 100%;
                  height: 100%;
                }
              }
              .goods-item-info {
                position: relative;
                min-height: 50px;
                overflow: hidden;
                .title {
                  overflow: hidden;
                  text-overflow: ellipsis;
                  white-space: nowrap;
                  line-height: 17px;
                  font-size: 14px;
                  color: #333;
                  margin-bottom: 5px;
                }
                .cart-price-single {
                  margin-top: 5px;
                  .tags-box {
                    line-height: 1;
                    .promotion-tags {
                      display: inline-block;
                      padding: 0 3px;
                      font-size: 10px;
                      height: 14px;
                      line-height: 14px;
                      border-radius: 4px 1px;
                      color: #fff;
                      z-index: 1;
                      box-sizing: border-box;
                    }
                    .promotion-tags-full {
                      margin-right: 3px;
                    }
                  }
                  .goods-price {
                    display: inline-block;
                  }
                  .single-price {
                    margin-top: 10px;
                    .row {
                      flex-wrap: wrap;
                      .real_Price {
                        padding-right: 5px;
                        color: #ff3434;
                      }
                      .basic_Price {
                        padding-right: 5px;
                        text-decoration: line-through;
                        color: #999;
                      }
                    }
                  }
                }
                .addCart {
                  flex-direction: row-reverse;
                }
                .add-cart {
                  position: absolute;
                  right: 0;
                  bottom: 0;
                  display: flex;
                  .add {
                    background-image: url("http://127.0.0.1:8088/upload/op.455b25b1.png");
                    background-repeat: no-repeat;
                    background-size: 100%;
                    width: 27px;
                    height: 27px;
                    vertical-align: top;
                    border: 0 solid transparent;
                    -webkit-background-origin: content-box;
                    background-origin: content-box;
                  }
                  .num {
                    width: 30px;
                    overflow: hidden;
                    height: 27px;
                    line-height: 27px;
                    text-align: center;
                    font-size: 16px;
                  }
                  .minus {
                    background-image: url("http://127.0.0.1:8088/upload/op.455b25b1.png");
                    background-position: 0 100%;
                    background-repeat: no-repeat;
                    background-size: 100%;
                    width: 27px;
                    height: 27px;
                    vertical-align: top;
                    border: 0 solid transparent;
                    -webkit-background-origin: content-box;
                    background-origin: content-box;
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}
.hide {
  display: none;
}
.bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: 50px;
  z-index: 1003;
  background-color: #fff;
  transition: left 0.6s;
}
.ipx-pad {
  padding-bottom: env(safe-area-inset-bottom);
  .cart-icon {
    width: 50px;
    height: 50px;
    background: url("http://127.0.0.1:8088/upload/cart.2da9496d.png") no-repeat;
    background-size: 50px;
    background-position: 0 100%;
  }
  .icon {
    position: absolute;
    left: 10px;
    top: -10px;
    opacity: 1;
    z-index: 41;
    -webkit-transition: top 0.6s;
    transition: top 0.6s;
    .cart-icon-point {
      position: absolute;
      top: -5px;
      left: 33px;
      right: auto;
      min-width: 18px;
      height: 18px;
      .mJQBuZ {
        display: inline-block;
        background-color: initial;
      }
      .mXYyd4 {
        color: #fff !important;
        font-size: 10px !important;
      }
    }
    .m320z8 {
      display: flex;
      justify-content: center;
      align-items: center;
      line-height: 16px;
      border-radius: 32px;
      z-index: 1;
      background-color: #ff5757 !important;
    }
  }
  .price {
    position: absolute;
    z-index: 40;
    left: 70px;
    right: 110px;
    bottom: 0;
    top: 0;
    transition: left 0.6s;
    .price-warp {
      height: 50px;
      display: table-cell;
      vertical-align: middle;
      .price-span {
        display: inline-block;
        padding-right: 5px;
        line-height: 22px;
        font-size: 22px;
        color: #ff3434;
      }
      .discount {
        padding-left: 5px;
        font-size: 12px;
        color: #999;
        display: inline-block;
        line-height: 12px;
      }
    }
  }
  .open {
    left: 10px;
  }
  .btn {
    position: absolute;
    z-index: 40;
    right: 0;
    width: 110px;
    .ui-flexbox {
      align-items: center;
      display: flex;
      position: relative;
      .mJQBuZ {
        display: inline-block;
        background-color: initial;
      }
    }
    .h-center {
      justify-content: center;
    }
  }
}
</style>



